From: Owen W. Taylor Date: Tue, 13 Sep 2016 13:03:53 +0000 (-0400) Subject: ostree-repo.c: Fix file descriptor cleanup X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~46^2~14 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=a5af1cb6888a2e4de5534be7623d08be277b801a;p=ostree.git ostree-repo.c: Fix file descriptor cleanup 0 was used as an "unset" flag for tmp_dir_fd, which is technically incorrect. For cache_dir_fd, -1 was used as the sentinal but 0 was checked for, resulting in close(-1). Closes: #507 Approved by: cgwalters --- diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index e4e1ecbf..d4b1f1d6 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -516,9 +516,9 @@ ostree_repo_finalize (GObject *object) g_free (self->commit_stagedir_name); glnx_release_lock_file (&self->commit_stagedir_lock); g_clear_object (&self->tmp_dir); - if (self->tmp_dir_fd) + if (self->tmp_dir_fd != -1) (void) close (self->tmp_dir_fd); - if (self->cache_dir_fd) + if (self->cache_dir_fd != -1) (void) close (self->cache_dir_fd); if (self->objects_dir_fd != -1) (void) close (self->objects_dir_fd); @@ -702,6 +702,7 @@ ostree_repo_init (OstreeRepo *self) self->repo_dir_fd = -1; self->cache_dir_fd = -1; + self->tmp_dir_fd = -1; self->commit_stagedir_fd = -1; self->objects_dir_fd = -1; self->uncompressed_objects_dir_fd = -1;